export const systemInfo = {
	state: {
		navBarConf: {},
		navBarHeightRpx: 0,
		ModularHeight: 0,
		safeAreaInsetsBottom: 0,
		isClickChildCom: false,
	},
	mutations: {
		setNavBarConf(state) { // 获取标题栏高度
			uni.getSystemInfo({
				success: function (res) {
					const titleBarHeight = 44
					state.navBarConf = Object.assign({
						titleBarHeight
					}, res)
					state.navBarHeightRpx = 750 / res.screenWidth * (titleBarHeight + res
						.statusBarHeight)
				}
			})
		},
		SET_IS_CLICK_CHILD_COM(state, payload) { // 设置isClickChildCom
			state.isClickChildCom = payload
		}
	},
	actions: {
		getModularHeight({ // 获取上边界
			state
		}, selector) {
			uni.getSystemInfo({
				success: (resu) => {
					const query = uni.createSelectorQuery()
					query.select(selector).boundingClientRect()
					query.selectViewport().scrollOffset()
					query.exec(function (res) {
						console.log(res,'获取上边界')
						state.ModularHeight = res[0].top
					})
				}
			})
		},
		getSafeAreaInsets({ // 获取安全区域底部高度
			state
		}) {
			if (uni.getSystemInfoSync().platform === 'ios' || uni.getSystemInfoSync().platform === 'devtools') {
				uni.getSystemInfo({
					success: function (res) {
						console.log(res,'获取安全区域底部高度')
						state.safeAreaInsetsBottom = res.safeAreaInsets.bottom + 75
					}
				})
			}
		}
	},
	getters: {
		getNavBarConf: (state) => state.navBarConf,
		getModularTop: (state) => state.ModularHeight,
		getSafeAreaInsetsHeight: (state) => state.safeAreaInsetsBottom,
		isClickChildCom: (state) => state.isClickChildCom
	}
}
